//------------ AER PNP Replication Cubas et. al.------------//

	use "$data/1_public_data/C_ATUS_CPS_Table4/data_final", clear


	******creating variables************

	keep if fullpart==1
	keep if age>=18 & age<=65

	replace uhrswork1=. if uhrswork1>99
	replace uhrswork2=. if uhrswork2>99
	replace uhrsworkt=. if uhrsworkt>999 

	* log hourly wage constructed
	* earnweek is available only for wage and salary
	replace earnweek=. if earnweek>99999

	* topcoded at $2884.61
	gen topcode = 2884.61
	replace earnweek= earnweek*1.5 if earnweek>=topcode
	gen earnhour=earnweek/uhrsworkt

	gen lhourwage=log(earnhour)

	*age variable
	gen age2=age*age
	gen age3=age2*age
	gen age4=age3*age
	*gender dummy
	gen female=(sex==2)

	gen twork_h=twork_1h+twork_2h+twork_3h+twork_4h+twork_5h+twork_6h+twork_7h+twork_8h+twork_9h+twork_10h+twork_11h+twork_12h+twork_13h+twork_14h+twork_15h+twork_16h+twork_17h+twork_18h+twork_19h+twork_20h+twork_21h+twork_22h+twork_23h+twork_24h
	gen twork_w=twork_1w+twork_2w+twork_3w+twork_4w+twork_5w+twork_6w+twork_7w+twork_8w+twork_9w+twork_10w+twork_11w+twork_12w+twork_13w+twork_14w+twork_15w+twork_16w+twork_17w+twork_18w+twork_19w+twork_20w+twork_21w+twork_22w+twork_23w+twork_24h
	gen twork_et=twork_1et+twork_2et+twork_3et+twork_4et+twork_5et+twork_6et+twork_7et+twork_8et+twork_9et+twork_10et+twork_11et+twork_12et+twork_13et+twork_14et+twork_15et+twork_16et+twork_17et+twork_18et+twork_19et+twork_20et+twork_21et+twork_22et+twork_23et+twork_24h

	gen twork=twork_h+twork_w+twork_et

	gen tcaring= tcaring_8to5+tcaring_5to4+tcaring_4to8
	gen tcaring_h=tcaring/60
	gen tcaring_8to5_h=tcaring_8to5/60
	gen tcaring_8to5_dum=(tcaring_8to5>0)
	gen twork_hours=twork/60
	
	// Summary Stats 
	tabstat race, by(race) 
	tab hispan if race==100
	gen White=0
		replace White=1 if race==100&hispan==100
	gen Black=(race==110)
	gen Asian=(race==131)
	gen Hispanic=0
		replace Hispanic=1 if hispan!=100
	gen EducBAHighest=(educ==40)
	tab fullpart
	tab educ
	
	sum age female White Black  Hispanic Asian EducBAHighest  [aw=wt06]  if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & earnhour!=.
		
	// Summary Stats of ANY INTERUPTION
	tabstat tcaring_8to5_dum [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0, by(sex)
	// Summary Stats of AMOUNT INTERUPTION
	tabstat tcaring_8to5_h [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0, by(sex)	
	tabstat lhourwage earnhour [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0, by(sex)
	
	*Original regression for men
	xi: reg lhourwage tcaring_8to5_dum uhrsworkt i.age i.educ i.race i.year [aw=wt06] if female==0 & marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 
	estimates store Cubas_Male
	* add mean for non-disclosers by gender
	qui sum lhourwage [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0
	qui estadd scalar ymean_male `r(mean)': Cubas_Male
	qui sum lhourwage [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1
	qui estadd scalar ymean_female `r(mean)': Cubas_Male

	//Table for appendix
	global sumstats_vars "tcaring_8to5_dum tcaring_8to5_h lhourwage earnhour"
	global formats "fmt( %12.2fc   %12.2fc  %12.2fc  %12.0fc )"
	label var tcaring_8to5_dum "Ext: Incidence of HH care 8 to 5"
	label var tcaring_8to5_h "Int: Hours of HH care 8 to 5"
	label var female "Female"
	label var lhourwage "Log Hourly Wage"
	label var earnhour "Hourly Wage"

		global myopts "bf(%15.3fc) sfmt(%15.3fc) prehead(\begin{tabular}{l*{14}{c}}) postfoot(\hline\hline \end{tabular}) se label noisily noeqlines nonumbers varlabels(_cons Constant, end("" ) nolast)  starlevels(* 0.1 ** 0.05 *** 0.01) replace"	
	
//Comparisons by type of occupation 
drop _merge
merge m:1 occ1990u using "$data/1_public_data/C_ATUS_CPS_Table4/BGS_ATUS_HighVSLowPoweredJobs_v3_Categorized.dta"
drop if _merge==2
gen HighPoweredJob=(RA_Category_V2=="High Powered")	

tabstat tcaring_8to5_dum tcaring_8to5_h lhourwage earnhour earnweek [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & earnhour!=. & HighPoweredJob==1, by(sex)
tabstat tcaring_8to5_dum tcaring_8to5_h lhourwage earnhour earnweek [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & earnhour!=. & HighPoweredJob==0, by(sex)
tabstat tcaring_8to5_dum tcaring_8to5_h lhourwage earnhour earnweek [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & earnhour!=., by(sex)	


global ATUSOutcomeVars "lhourwage"	
foreach var in  $ATUSOutcomeVars{
		
	*NON-LOG Version of Original regression adapated for avg male/female but control for gender and extensive and intensive margin
	xi: reg `var'  uhrsworkt female i.age i.educ i.race i.year [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0		
	estimates store BothGenders`var'
	* add mean for non-disclosers by gender
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 
	qui estadd scalar ymean_both_2 `r(mean)': BothGenders`var'	
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0
	qui estadd scalar ymean_male_2 `r(mean)': BothGenders`var'
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1
	qui estadd scalar ymean_female_2 `r(mean)': BothGenders`var'
	qui sum tcaring_8to5_dum [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0
	qui estadd scalar ymean_male_3 `r(mean)': BothGenders`var'
	qui sum tcaring_8to5_dum [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1
	qui estadd scalar ymean_female_3 `r(mean)': BothGenders`var'
	qui sum tcaring_8to5_h [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0
	qui estadd scalar ymean_male_4 `r(mean)': BothGenders`var'
	qui sum tcaring_8to5_h [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1
	qui estadd scalar ymean_female_4 `r(mean)': BothGenders`var'	

	*NON-LOG Version of Original regression adapated for avg male/female but control for gender and extensive and intensive margin
	xi: reg `var' tcaring_8to5_dum tcaring_8to5_h uhrsworkt female i.age i.educ i.race i.year [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0		
	estimates store ExtInt_BothGenders`var'
	* add mean for non-disclosers by gender
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 
	qui estadd scalar ymean_both_2 `r(mean)': ExtInt_BothGenders`var'		
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0
	qui estadd scalar ymean_male_2 `r(mean)': ExtInt_BothGenders`var'
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1
	qui estadd scalar ymean_female_2 `r(mean)': ExtInt_BothGenders`var'		
	qui sum tcaring_8to5_dum [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0
	qui estadd scalar ymean_male_3 `r(mean)': ExtInt_BothGenders`var'
	qui sum tcaring_8to5_dum [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1
	qui estadd scalar ymean_female_3 `r(mean)': ExtInt_BothGenders`var'	
	qui sum tcaring_8to5_h [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0
	qui estadd scalar ymean_male_4 `r(mean)': ExtInt_BothGenders`var'
	qui sum tcaring_8to5_h [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1
	qui estadd scalar ymean_female_4 `r(mean)': ExtInt_BothGenders`var'
	

forvalues i=0/1 {

	*NON-LOG Version Original regression adapated for avg male/female but NO controls household interupptions but with controls for gender
	xi: reg `var' uhrsworkt female i.age i.educ i.race i.year [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & HighPoweredJob==`i'	
	estimates store NoCare2HP`i'`var'
	* add mean for non-disclosers by gender
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & HighPoweredJob==`i'
	qui estadd scalar ymean_both_2 `r(mean)': NoCare2HP`i'`var'			
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0 & HighPoweredJob==`i'
	qui estadd scalar ymean_male_2 `r(mean)': NoCare2HP`i'`var'
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1 & HighPoweredJob==`i'
	qui estadd scalar ymean_female_2 `r(mean)': NoCare2HP`i'`var'
	qui sum tcaring_8to5_dum [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0 & HighPoweredJob==`i'
	qui estadd scalar ymean_male_3 `r(mean)': NoCare2HP`i'`var'
	qui sum tcaring_8to5_dum [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1 & HighPoweredJob==`i'
	qui estadd scalar ymean_female_3 `r(mean)': NoCare2HP`i'`var'
	qui sum tcaring_8to5_h [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0 & HighPoweredJob==`i'
	qui estadd scalar ymean_male_4 `r(mean)': NoCare2HP`i'`var'
	qui sum tcaring_8to5_h [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1 & HighPoweredJob==`i'
	qui estadd scalar ymean_female_4 `r(mean)': NoCare2HP`i'`var'	
	
*NON-LOG Version of Original regression adapated for avg male/female but control for gender
	xi: reg `var' tcaring_8to5_dum tcaring_8to5_h uhrsworkt female i.age i.educ i.race i.year [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & HighPoweredJob==`i'		
	estimates store ExtInt_HP`i'`var'
	* add mean for non-disclosers by gender
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & HighPoweredJob==`i'
	qui estadd scalar ymean_both_2 `r(mean)': ExtInt_HP`i'`var'	
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0 & HighPoweredJob==`i'	
	qui estadd scalar ymean_male_2 `r(mean)': ExtInt_HP`i'`var'
	qui sum `var' [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1 & HighPoweredJob==`i'	
	qui estadd scalar ymean_female_2 `r(mean)': ExtInt_HP`i'`var'	
	qui sum tcaring_8to5_dum [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0 & HighPoweredJob==`i'
	qui estadd scalar ymean_male_3 `r(mean)': ExtInt_HP`i'`var'
	qui sum tcaring_8to5_dum [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1 & HighPoweredJob==`i'
	qui estadd scalar ymean_female_3 `r(mean)': ExtInt_HP`i'`var'
	qui sum tcaring_8to5_h [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==0 & HighPoweredJob==`i'
	qui estadd scalar ymean_male_4 `r(mean)': ExtInt_HP`i'`var'
	qui sum tcaring_8to5_h [aw=wt06] if marst==1 & hh_numkids>0 & day~=1 & day~=7 & twork_w>0 & female==1 & HighPoweredJob==`i'
	qui estadd scalar ymean_female_4 `r(mean)': ExtInt_HP`i'`var'
	}

esttab BothGenders`var' ExtInt_BothGenders`var' NoCare2HP0`var' ExtInt_HP0`var' NoCare2HP1`var' ExtInt_HP1`var' using "$output/tables/Table_4.tex" ,  $myopts keep(tcaring_8to5_dum tcaring_8to5_h female) order(tcaring_8to5_dum tcaring_8to5_h female) scalars("r2_a R$^2 $" "a1 Mean hourly wages" "ymean_both_2 Male \& Female" "ymean_male_2 Male" "ymean_female_2 Female" "b1 Ext: Any HH care 8 to 5" "ymean_male_3 Male" "ymean_female_3 Female" "c1 Int: Hours HH care 8 to 5" "ymean_male_4 Male" "ymean_female_4 Female" )   collabels(none) obslast mtitle( "\Centerstack{(1) \! Without \! Household \! Care \!}" "\Centerstack{(2) \! With \! Household \! Care} \!" "\Centerstack{(3) \! Low-Powered \! Jobs Without \! Household \! Care}" "\Centerstack{(4) \! Low-Powered  \! Jobs With \! Household \! Care }" "\Centerstack{(5) \! High-Powered \! Jobs Without \! Household \! Care }" "\Centerstack{(6) \! High-Powered \! Jobs  With \! Household \! Care }")

	
}
